import { AES, enc, pad, mode } from 'crypto-js'

/**
 * aes加密
 * @param content 加密内容
 * @param key 秘钥
 */
export const AESEncode = (content: string, key: string) =>
  AES.encrypt(content, enc.Utf8.parse(key), {
    mode: mode.ECB,
    padding: pad.Pkcs7,
  }).toString()

/**
 * aes解密
 * @param content 加密内容
 * @param key 秘钥
 */
export const AESDecode = (content: string, key: string) =>
  AES.decrypt(content, enc.Utf8.parse(key), {
    mode: mode.ECB,
    padding: pad.Pkcs7,
  }).toString(enc.Utf8)
